package day12;

import java.io.File;
import java.util.HashMap;

public class test3 {
    public static void main(String[] args) {
        File file=new File("study\\src\\day12") ;
        HashMap<String,Integer> hm=new HashMap<>();
        getCount(hm,file);
        System.out.println(hm);
    }

    private static void getCount(HashMap<String, Integer> hm, File file) {
        File[] files = file.listFiles();
        for (File f : files) {
          if (f.isFile()) {
              String fileName = f.getName();
              String[] fileNameArr = fileName.split("\\.");
              if (fileNameArr.length==2){
                  String fileEndName=fileNameArr[1];
                  if (hm.containsKey(fileEndName)){
                      Integer count = hm.get(fileEndName);
                      count++;
                      hm.put(fileEndName,count);

                  }else {
                      hm.put(fileEndName,1);
                  }
              }

          }else {
              getCount(hm,f);
          }
        }
    }
}
